/* GUI CONVERTED from icccaj.p (converter v1.76) Wed Dec  4 04:08:52 2002 */
/* icccaj.p - CYCLE COUNT RESULTS                                       */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.32 $                                                         */

/* REVISION: 1.0      LAST MODIFIED: 07/12/86   BY: EMB */
/* REVISION: 6.0      LAST MODIFIED: 03/14/90   BY: emb *D002**/
/* REVISION: 6.0      LAST MODIFIED: 04/03/90   BY: WUG *D015**/
/* REVISION: 6.0      LAST MODIFIED: 12/11/90   BY: emb *D242**/
/* REVISION: 6.0      LAST MODIFIED: 12/17/90   BY: WUG *D619**/
/* REVISION: 6.0      LAST MODIFIED: 04/12/91   BY: WUG *D525**/
/* REVISION: 6.0      LAST MODIFIED: 04/26/91   BY: WUG *D589**/
/* REVISION: 6.0      LAST MODIFIED: 08/01/91   BY: emb *D800*/
/* REVISION: 7.0      LAST MODIFIED: 09/04/91   BY: pma *F003*          */
/* REVISION: 6.0      LAST MODIFIED: 11/11/91   BY: WUG *D887*          */
/* REVISION: 7.0      LAST MODIFIED: 02/03/92   BY: pma *F141*          */
/* REVISION: 7.0      LAST MODIFIED: 02/03/92   BY: pma *F172*          */
/* REVISION: 7.0      LAST MODIFIED: 06/18/92   BY: JJS *F672*(rev only)*/
/* REVISION: 7.0      LAST MODIFIED: 07/10/92   BY: pma *F757*          */
/* REVISION: 7.0      LAST MODIFIED: 02/03/93   BY: dzs *G632*          */
/* REVISION: 7.4      LAST MODIFIED: 07/22/93   BY: pcd *H039*          */
/* REVISION: 7.4      LAST MODIFIED: 02/16/94   BY: pxd *FL60*          */
/* REVISION: 7.4      LAST MODIFIED: 08/18/94   BY: srk *FQ31*          */
/* REVISION: 7.2      LAST MODIFIED: 11/20/94   BY: qzl *FT92*          */
/* REVISION: 7.5      LAST MODIFIED: 01/23/94   BY: taf *J038*          */
/* REVISION: 8.5      LAST MODIFIED: 09/18/95   BY: sxb *J053*          */
/* REVISION: 8.5      LAST MODIFIED: 05/01/96   BY: jym *G1MN*          */
/* REVISION: 7.3      LAST MODIFIED: 05/16/96   BY: rvw *G1S8*          */
/* REVISION: 8.5      LAST MODIFIED: 06/10/96   BY: jym *G1XS*          */
/* REVISION: 8.6      LAST MODIFIED: 06/11/96   BY: ejh *K001*          */
/* REVISION: 8.5      LAST MODIFIED: 07/31/96   BY: *G29S*  Russ Witt       */
/* REVISION: 8.5      LAST MODIFIED: 08/23/96   BY: *G2CW*  Russ Witt       */
/* REVISION: 8.6      LAST MODIFIED: 09/29/97   BY: *J1PS*  Felcy D'Souza   */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane        */
/* REVISION: 8.6E     LAST MODIFIED: 05/13/98   BY: *J2DD* Kawal Batra      */
/* REVISION: 8.6E     LAST MODIFIED: 05/09/98   BY: *L00Y* Jeff Wootton     */
/* REVISION: 8.6E     LAST MODIFIED: 07/06/98   BY: *L034* Markus Barone    */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Murali Ayyagari  */
/* REVISION: 9.1      LAST MODIFIED: 12/13/99   BY: *L0ML* Jyoti Thatte     */
/* REVISION: 9.1      LAST MODIFIED: 01/19/00   BY: *N077* Vijaya Pakala    */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00   BY: *N0KS* myb              */
/* Old ECO marker removed, but no ECO header exists *F0PN*                  */
/* Revision: 1.25     BY: Ellen Borden        DATE: 10/26/01  ECO: *P00G*   */
/* Revision: 1.26     BY: Veena Lad           DATE: 05/08/02  ECO: *N1J0*   */
/* Revision: 1.30     BY: Steve Nugent        DATE: 06/10/02  ECO: *P07Y*   */
/* Revision: 1.31     BY: Manjusha Inglay     DATE: 08/16/02  ECO: *N1QP*   */
/* $Revision: 1.32 $   BY: Anitha Gopal        DATE: 12/03/02  ECO: *N217*   */
/* $Revision: eb2 sp3 $   BY: Joy Huang       DATE: 10/31/03  ECO: *HK-S-015*    */

/*V8:ConvertMode=Maintenance                                                */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdtitle.i "2+ "}

{gldydef.i new}
{gldynrm.i new}

define variable yn like mfc_logical.
define variable cc_initial like mfc_logical format "Initial/Recount"
   initial yes label "Cycle Count Type (I/R)" no-undo.
define variable tol     like icc_tol_a    label "Tolerance Amount"      no-undo.
define variable tol%    like icc_tol_a%   label "Tolerance Percentage"  no-undo.
define variable qty_cnt like in_qty_oh    label "Quantity Counted"      no-undo.
define variable qty_oh_var like icc_tol_a%
                                          label "Qty On Hand Variance"  no-undo.
define variable avg_iss_var like icc_tol_a%
                                          label "Annual Usage Variance" no-undo.
define variable dollar_var like icc_tol_a label "Amount Variance"       no-undo.
define variable um like pt_um             label "Unit of Measure"       no-undo.
define variable conv like um_conv.
define variable eff_date like glt_effdate label "Effective Date"        no-undo.
define variable ref like glt_ref.
define variable part like pt_part no-undo.
define variable site like ld_site no-undo.
define variable location like ld_loc no-undo.
define variable lotserial like ld_lot no-undo.
define variable dr_acct like trgl_dr_acct no-undo.
define variable dr_sub like trgl_dr_sub no-undo.
define variable dr_cc   like trgl_dr_cc no-undo.
define variable cr_acct like trgl_cr_acct no-undo.
define variable cr_sub like trgl_cr_sub no-undo.
define variable cr_cc   like trgl_cr_cc no-undo.
define variable gl_amt like glt_amt.
define variable qty_oh like ld_qty_oh.
define variable transtype like tr_type.
define variable rmks like tr_rmks.
define variable lotref like ld_ref label "Reference" no-undo.
define variable undo-input like mfc_logical.
define variable isvalidacct like mfc_logical.
define variable trans-ok like mfc_logical no-undo.
define variable gl_tmp_amt as decimal.
define variable gl_amt_fmt as character.
define variable show-usage-var like mfc_logical.
define variable inrecno as recid no-undo.

/*CUSTOMER CONSIGNMENT VARIABLES*/
{socnvars.i}
define variable consigned_line             like mfc_logical  no-undo.
define variable consigned_qty_oh           like ld_qty_oh    no-undo.
define variable consigned_cc_qty           like ld_qty_oh    no-undo.
define variable unconsigned_qty            like ld_qty_oh    no-undo.
define variable procid                     as character      no-undo.
define variable hold_trnbr                 like tr_trnbr     no-undo.

/*SUPPLIER CONSIGNMENT VARIABLES */
define variable ENABLE_SUPPLIER_CONSIGNMENT
       as character initial "enable_supplier_consignment"    no-undo.
define variable SUPPLIER_CONSIGN_CTRL_TABLE
       as character initial "cns_ctrl"                       no-undo.
define variable using_supplier_consignment as logical        no-undo.
define variable supp_consign_qty           like ld_qty_oh    no-undo.
define variable over_consigned_qty         like ld_qty_oh    no-undo.
define variable io_batch                   like cnsu_batch   no-undo.

{gpglefv.i}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
space(1)
   cc_initial     skip(1)
   part           colon 20
   icc_tol_flag   colon 62
   site           colon 20
   tol%           colon 62
   location       colon 20
   tol            colon 62
   lotserial      colon 20
/*HK-S-015   glxcst         colon 62*/
   lotref         colon 20 format "x(8)"
   ld_cnt_date    colon 62
   pt_desc1       colon 20
   ld_qty_oh      colon 62 format "->>,>>>,>>9.9<<<<<<<<"
   label "Qty On Hand"
   pt_desc2       colon 22 no-label
   qty_cnt        colon 20
   qty_oh_var     colon 62 format "->>>>>>.99%"
   um             colon 20
   avg_iss_var    colon 62 format "->>>>>>.99%"
   conv           colon 20
   dollar_var     colon 62
   skip(1)
   rmks           colon 20
   eff_date       colon 20
   dr_acct        colon 20 label "Dr Acct"
   dr_sub         no-label
   dr_cc          no-label
   cr_acct        label "Cr"
   cr_sub         no-label
   cr_cc          no-label
   gl_amt         colon 20
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

find first gl_ctrl no-lock.

eff_date = today.

/* DETERMINE IF SUPPLIER CONSIGNMENT IS ACTIVE */
{gprun.i ""gpmfc01.p""
   "(input ENABLE_SUPPLIER_CONSIGNMENT,
     input 11,
     input ADG,
     input SUPPLIER_CONSIGN_CTRL_TABLE,
     output using_supplier_consignment)"}
/*GUI*/ if global-beam-me-up then undo, leave.


repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.

   update cc_initial with frame a.

   find first icc_ctrl no-lock.

   loopb:
   repeat on error undo, retry with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.

      assign
         qty_cnt = 0
         qty_oh_var = 0
         avg_iss_var = 0
         dollar_var = 0
         transtype = "CYC-CNT".
      update part with frame a
      editing:
         global_part = input part.
         /* FIND NEXT/PREVIOUS */
         {mfnp.i pt_mstr part pt_part part pt_part pt_part}

         if recno<> ? then do:
            display
               pt_part @ part
               pt_desc1
               pt_desc2
               pt_um   @ um
               pt_site @ site
               pt_loc  @ location
               ""      @ lotserial
               ""      @ lotref.
         end.
      end.

      find pt_mstr where pt_part = part no-lock no-error.
      if not available pt_mstr then do:
         {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3} /*Item master does not exist*/
         undo, retry.
      end.
      assign
         site = pt_site
         lotserial = ""
         lotref    = ""
         location = pt_loc.

      do on error undo loopb, retry loopb:
         run ip-upd-frm-a.
      end.

      if (lotserial <> "") then do:
         {gprun.i ""gpltfnd.p"" "(part,
              lotserial,
              """",
              """",
              """",
              output trans-ok)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         if not trans-ok then do:
            undo loopb, retry.
         end.
      end.

      find pl_mstr where pl_prod_line = pt_prod_line no-lock.

      find pld_det where pld_prodline = pt_prod_line
         and pld_site = site and pld_loc = location no-lock no-error.
      if not available pld_det then do:
         find pld_det where pld_prodline = pt_prod_line
            and pld_site = site and pld_loc = "" no-lock no-error.
         if not available pld_det then do:
            find pld_det where pld_prodline = pt_prod_line
               and pld_site = "" and pld_loc = "" no-lock no-error.
         end.
      end.

      find ld_det where ld_part = part
         and ld_site = site
         and ld_loc = location
         and ld_lot = lotserial
         and ld_ref = lotref
      no-lock no-error.
      if available ld_det then recno = recid(ld_det).

      find si_mstr where si_site = site no-lock no-error.
      {gprun.i ""gpincr.p"" "(input no,
           input part,
           input site,
           input if available si_mstr then
           si_gl_set
           else """",
           input if available si_mstr then
           si_cur_set
           else """",
           input if available pt_mstr then
           pt_abc
           else """",
           input if available pt_mstr then
           pt_avg_int
           else 0,
           input if available pt_mstr then
           pt_cyc_int
           else 0,
           input if available pt_mstr then
           pt_rctpo_status
           else """",
           input if available pt_mstr then
           pt_rctpo_active
           else no,
           input if available pt_mstr then
           pt_rctwo_status
           else """",
           input if available pt_mstr then
           pt_rctwo_active
           else no,
           output inrecno)"
         }
/*GUI*/ if global-beam-me-up then undo, leave.


      find in_mstr where recid(in_mstr) = inrecno
      no-lock no-error.

      find ptp_det no-lock where ptp_part = in_part
         and ptp_site = in_site no-error.

      {gpsct03.i &cost=sct_cst_tot}

      qty_oh = 0.
      if available ld_det then qty_oh = ld_qty_oh.

      global_part = pt_part.

      if in_abc = "a" then do:
         tol = icc_tol_a.
         tol% = icc_tol_a%.
      end.
      else if in_abc = "b" then do:
         tol = icc_tol_b.
         tol% = icc_tol_b%.
      end.
      else if in_abc = "c" then do:
         tol = icc_tol_c.
         tol% = icc_tol_c%.
      end.
      else do:
         tol = icc_tol_o.
         tol% = icc_tol_o%.
      end.

      if available pld_det then do:
         assign
            dr_acct = pld_inv_acct
            dr_sub  = pld_inv_sub
            dr_cc   = pld_inv_cc
            cr_acct = pld_dscracct
            cr_sub  = pld_dscr_sub
            cr_cc   = pld_dscr_cc.
      end.
      else do:
         assign
            dr_acct = pl_inv_acct
            dr_sub  = pl_inv_sub
            dr_cc   = pl_inv_cc
            cr_acct = pl_dscr_acct
            cr_sub  = pl_dscr_sub
            cr_cc   = pl_dscr_cc.
      end.

      um = pt_um.
      conv = 1.

      display pt_desc1 pt_desc2 um
/*HK-S-015           qty_oh @ ld_qty_oh glxcst*/
/*HK-S-015*/         qty_oh @ ld_qty_oh
         dr_acct dr_cc cr_acct cr_cc
         dr_sub cr_sub
         tol tol% icc_tol_flag.

      if available ld_det then
         if ld_cnt_date = ? then display in_cnt_date @ ld_cnt_date.
      else display ld_cnt_date.

      update qty_cnt um conv with frame a.

      /* CALCULATE UM CONVERSION */

      /* ALLOW UOM CONVERSION WHEN*/
      /* ENTERING THE QUANTITY WITH A DIFFERENT VALID UOM */

      if um <> pt_um then do:
         if not conv entered then do:
            {gprun.i ""gpumcnv.p""
               "(input um, input pt_um, input pt_part, output conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            if conv = ? then do:
               {pxmsg.i &MSGNUM=33 &ERRORLEVEL=2}
               conv = 1.
            end.
            display conv with frame a.
         end.
      end.

      qty_cnt = qty_cnt * conv.

      /*CALCULATE GL AMOUNT*/
      gl_amt = (qty_cnt - qty_oh) * glxcst.
      {gprun.i ""gpcurrnd.p"" "(input-output gl_amt,
           input gl_rnd_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      gl_amt_fmt = gl_amt:format.
      {gprun.i ""gpcurfmt.p"" "(input-output gl_amt_fmt,
           input gl_rnd_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      gl_amt:format = gl_amt_fmt.
      display gl_amt.

      /*CALCULATE TOLERANCES */
      qty_oh_var = ((1 - qty_cnt / qty_oh) * 100).
      if qty_oh_var = ? and qty_cnt = 0 then qty_oh_var = 0.
      if qty_oh_var = ? and qty_cnt <> 0 then qty_oh_var = 100.
      if qty_oh_var < 0 then qty_oh_var = - qty_oh_var.

      avg_iss_var = 0.
      show-usage-var = yes.
      if in_avg_iss = 0 then do:
         if not qty_cnt = qty_oh then do:
            show-usage-var = no.
            if not icc_tol_flag then
            {pxmsg.i &MSGNUM=1292 &ERRORLEVEL=2}
            . /* ANNUAL USAGE VARIANCE CANNOT       */
            /* BE CALCULATED                      */
            avg_iss_var = 999999.99.
         end.
      end.
      else
      avg_iss_var =
      ((qty_cnt - qty_oh) / (in_avg_iss * 365)) * 100.
      if avg_iss_var < 0 then avg_iss_var = - avg_iss_var.

      dollar_var = (qty_cnt * glxcst) - (qty_oh * glxcst).
      {gprun.i ""gpcurrnd.p"" "(input-output dollar_var,
           input gl_rnd_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      if dollar_var < 0 then dollar_var = - dollar_var.
      gl_amt_fmt = dollar_var:format.
      {gprun.i ""gpcurfmt.p"" "(input-output gl_amt_fmt,
           input gl_rnd_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      dollar_var:format = gl_amt_fmt.
      display qty_oh_var.
      if show-usage-var then display avg_iss_var.
      else display "" @ avg_iss_var.
      display dollar_var.

      if (icc_tol_flag and qty_oh_var > tol%) or (dollar_var > tol)
         or (not icc_tol_flag and avg_iss_var > tol%) then do:
         {pxmsg.i &MSGNUM=201 &ERRORLEVEL=2} /* Count is out of tolerance */
         if cc_initial then do:
            {pxmsg.i &MSGNUM=202 &ERRORLEVEL=1}
            /* Quantity on hand will not be changed */
         end.
         if cc_initial then transtype = "CYC-ERR".
      end.
      if cc_initial = no then transtype = "CYC-RCNT".

      if transtype = "CYC-ERR" then gl_amt = 0.

      {gprun.i ""icedit.p""
         "(transtype,
           site,
           location,
           part,
           lotserial,
           lotref,
           qty_cnt,
           um,
           """",
           """",
           output undo-input )"
         }
/*GUI*/ if global-beam-me-up then undo, leave.

      if undo-input then undo, retry.

      seta:
      do on error undo,retry:
/*GUI*/ if global-beam-me-up then undo, leave.

         update rmks
            eff_date
            cr_acct
            cr_sub
            cr_cc
         with frame a.

         /* CHECK GL EFFECTIVE DATE */
         find si_mstr where si_site = site no-lock no-error.
         {gpglef1.i
            &module = ""IC""
            &entity = si_entity
            &date = eff_date
            &prompt = "eff_date"
            &frame = "a"
            &loop = "seta"
            }

         /* CHECK GL ACCOUNT/COST CENTER */

         /* INITIALIZE SETTINGS */
         {gprunp.i "gpglvpl" "p" "initialize"}
         /* SET PROJECT VERIFICATION TO NO */
         {gprunp.i "gpglvpl" "p" "set_proj_ver" "(input false)"}
         /* CHECK GL ACCOUNT/SUB ACCOUNT/COST CENTER */
         {gprunp.i "gpglvpl" "p" "validate_fullcode"
            "(input cr_acct,
              input cr_sub,
              input cr_cc,
              input """",
              output isvalidacct)"}

         if not isvalidacct then do:
            next-prompt cr_acct.
            undo, retry.
         end.
      end.
/*GUI*/ if global-beam-me-up then undo, leave.


      yn = yes.
      {mfmsg01.i 12 1 yn}
      if not yn then undo, retry.

      /* CHECK TO SEE IF CONSIGNMENT IS ACTIVE */
      {gprun.i ""gpmfc01.p""
         "(input ENABLE_CUSTOMER_CONSIGNMENT,
           input 10,
           input ADG,
           input CUST_CONSIGN_CTRL_TABLE,
           output using_cust_consignment)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if using_cust_consignment and qty_cnt < qty_oh then do:

         consigned_qty_oh = ld_cust_consign_qty.

         unconsigned_qty = qty_oh - consigned_qty_oh.
         if unconsigned_qty < (qty_oh - qty_cnt) then do:
            consigned_cc_qty = (qty_oh - qty_cnt) - unconsigned_qty.
         end.
      end. /*if using_cust_consignment*/

      /* SUPPLIER CONSIGNMENT */
      if using_supplier_consignment and qty_cnt < qty_oh then do:

         supp_consign_qty = ld_supp_consign_qty.

         over_consigned_qty = qty_oh - ld_supp_consign_qty.
         if over_consigned_qty < qty_oh - qty_cnt then assign
            supp_consign_qty = (qty_oh - qty_cnt) - over_consigned_qty.
      end.

      /* ADDED SECOND EXCHANGE RATE, TYPE, SEQUENCE */
      /* ADDED CRSUB DRSUB */
      {ictrans.i
         &addrid=""""
         &bdnstd=0
         &cracct=cr_acct
         &crsub=cr_sub
         &crcc=cr_cc
         &crproj=""""
         &curr=""""
         &dracct=dr_acct
         &drsub=dr_sub
         &drcc=dr_cc
         &drproj=""""
         &effdate=eff_date
         &exrate=0
         &exrate2=0
         &exratetype=""""
         &exruseq=0
         &glamt=gl_amt
         &lbrstd=0
         &line=0
         &location=location
         &lotnumber=""""
         &lotserial=lotserial
         &lotref=lotref
         &mtlstd=0
         &ordernbr=""""
         &ovhstd=0
         &part=part
         &perfdate=?
         &price=glxcst
         &quantityreq=qty_cnt
         &quantityshort=0
         &quantity="if transtype = ""CYC-ERR"" then 0
           else qty_cnt - qty_oh"
         &revision=""""
         &rmks=rmks
         &shiptype=""""
         &site=site
         &slspsn1=""""
         &slspsn2=""""
         &sojob=""""
         &substd=0
         &transtype=transtype
         &msg=0
         &ref_site=tr_site
         }
      assign
         hold_trnbr = tr_hist.tr_trnbr.

      if available in_mstr then in_cnt_date = eff_date.

      if using_cust_consignment and consigned_cc_qty > 0 and
         transtype <> "CYC-ERR" then do:

         /* BACKOUT THE CONSIGNED PORTION OF THE CYCLE COUNT THAT*/
         /* REPORTED.  CREATE A CONSIGNMENT USAGE FOR THAT PORTION*/
         /* THAT IS BACKED OUT.                                   */
         {ictrans.i
            &addrid=""""
            & bdnstd=0
            &cracct=cr_acct
            &crsub=cr_sub
            &crcc=cr_cc
            &crproj=""""
            &curr=""""
            &dracct=dr_acct
            &drsub=dr_sub
            &drcc=dr_cc
            &drproj=""""
            &effdate=eff_date
            &exrate=0
            &exrate2=0
            &exratetype=""""
            &exruseq=0
            &glamt="gl_amt * -1"
            &lbrstd=0
            &line=0
            &location=location
            &lotnumber=""""
            &lotserial=lotserial
            &lotref=lotref
            &mtlstd=0
            &ordernbr=""""
            &ovhstd=0
            &part=part
            &perfdate=?
            &price=glxcst
            &quantityreq="qty_cnt + consigned_cc_qty"
            &quantityshort=0
            &quantity=consigned_cc_qty
            &revision=""""
            &rmks=string(hold_trnbr)
            &shiptype=""""
            &site=site
            &slspsn1=""""
            &slspsn2=""""
            &sojob=""""
            &substd=0
            &transtype=""CN-CNT""
            &msg=0
            &ref_site=tr_site
            }

         {gprunmo.i
            &program = "socnuse.p"
            &module = "ACN"
            &param = """(input part,
              input site,
              input location,
              input lotserial,
              input lotref,
              input um,
              input consigned_cc_qty,
              input transtype)"""}

      end. /* If using_cust_consignment*/

      if using_supplier_consignment and supp_consign_qty > 0 and
         transtype <> "CYC-ERR" then do:

         {gprunmo.i
            &program = ""ictrancn.p""
            &module  = "ACN"
            &param   =  """(input '',
                            input '',
                            input 0,
                            input '',
                            input supp_consign_qty,
                            input lotserial,
                            input part,
                            input site,
                            input location,
                            input lotref,
                            input eff_date,
                            input hold_trnbr,
                            input FALSE,
                            input-output io_batch)"""}

      end. /* IF using_supplier_consignment */

      run find-ld-det.

   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /*loopb*/
end.
/*GUI*/ if global-beam-me-up then undo, leave.


PROCEDURE find-ld-det:

   /* TO AVOID DEAD-LOCK BETWEEN SESSIONS, RELEASING THE LOCK ON    */
   /* ld_det RECORD. ALSO CHANGED THE LOCK TO EXCLUSIVE FROM SHARED */
   find ld_det where ld_site = site and ld_loc = location and
      ld_part = part and ld_lot = lotserial and ld_ref = lotref
      exclusive-lock no-error.
   if available ld_det then ld_cnt_date = eff_date.
   release ld_det.
END PROCEDURE.

PROCEDURE ip-upd-frm-a:

   /* THIS PROCEDURE WAS CREATED DUE TO COMPILE SIZE. */
   /* IT ALLOWS UPDATE OF SEVERAL FIELDS IN FRAME A.  */

   clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
   display
      cc_initial
      part
      site
      location
      lotserial
      lotref
   with frame a.

   do on endkey undo, return error:
      set
         site location lotserial lotref
         with frame a
      editing:
         assign
            global_site = input site
            global_loc = input location
            global_lot = input lotserial.

         if frame-field = "site" then do:
            /* FIND NEXT/PREVIOUS */
            {mfnp05.i ld_det ld_part_loc "ld_part = input part"
               ld_loc location}

            if recno<> ? then do:
               display ld_site @ site ld_loc @ location
                  ld_lot @ lotserial ld_ref format "x(8)" @ lotref
               with frame a.
            end.
         end.
         else
            if frame-field = "location" then do:
            /* FIND NEXT/PREVIOUS */
            {mfnp05.i ld_det ld_part_loc
               "ld_part = input part
                 and ld_site = input site" ld_loc location}

            if recno<> ? then do:
               display ld_site @ site ld_loc @ location
                  ld_lot @ lotserial ld_ref format "x(8)" @ lotref
               with frame a.
            end.
         end.
         else
            if frame-field = "lotserial" then do:
            /* FIND NEXT/PREVIOUS */
            {mfnp05.i ld_det ld_part_loc
               "ld_part = input part and ld_site = input site
                 and ld_loc = input location"
               ld_loc location}

            if recno<> ? then do:
               display ld_site @ site ld_loc @ location
                  ld_lot @ lotserial ld_ref format "x(8)" @ lotref
               with frame a.
            end.
         end.
         else do:
            status input.
            readkey.
            apply lastkey.
         end.
      end. /* EDITING */
   end. /* do on endkey */

END PROCEDURE.  /* ip-upd-frm-a */
